package com.example.dhhyc.demos.strategy.strategy3;

import java.util.List;

/**
 * Describe :
 * question :
 *
 * @author BaiShanshan
 * @date 2024/5/3 10:20
 */

public class ClientTest {
    public static void main(String[] args) {
        //模拟回执
        List<Receipt> receipts = ReceiptBuilder.genReceiptList();
        //策略上下文
        ReceiptStrategyContext context = new ReceiptStrategyContext();
        //策略模式将策略的 定义、创建、使用这三部分进行了解耦
        receipts.stream().forEach(receipt -> {
            //设置策略
            context.setReceiptHandleStrategy(ReceiptHandleStrategyFactory.getInvokeHandler(receipt.getType()));
            //执行策略
            context.handleReceipt(receipt);
        });

    }
}
